const baseUrl = 'http://localhost:8082'
//封装uni.request
const http = options=>{
	return new Promise((resolve,reject)=>{
		uni.request({
			url:baseUrl+options.url,
			method:options.method || "GET",
			data:options.data || {},
			success(res) {
				//后台数据自定义的状态值
				if(res.data.status!==0){
					return uni.showToast({
						title:'获取数据失败'
					})
				}
				resolve(res)
			},
			fail(err) {
				uni.showToast({
					title:"请求接口失败"
				})
				reject(err.message)
			}
		})
	})
}

export default http